home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Cursor / CursorController.cp next >
Text File  |  2000-06-23  |  2KB  |  83 lines

  1. // CursorController.cp
  2.  
  3. #ifndef CursorController_h
  4. #include "CursorController.h"
  5. #endif
  6. #ifndef UserState_h
  7. #include "UserState.h"
  8. #endif
  9. #ifndef CursorObject_h
  10. #include "CursorObject.h"
  11. #endif
  12. #ifndef CellCursorCollector_h
  13. #include "CellCursorCollector.h"
  14. #endif
  15. #ifndef WindowObject_h
  16. #include "WindowObject.h"
  17. #endif
  18. #ifndef MouseEvent_h
  19. #include "MouseEvent.h"
  20. #endif
  21. #ifndef Application_h
  22. #include "Application.h"
  23. #endif
  24. #ifndef AbstractWindow_h
  25. #include "AbstractWindow.h"
  26. #endif
  27.  
  28. CursorController::CursorController()
  29.   : current( &CursorObject::Arrow() ),
  30.      watchShowing( false ),
  31.      userStateChanged( UserState::The(), *this, &MouseWatcher::Invalidate )
  32.   {
  33.   }
  34.  
  35. CursorController& CursorController::The()
  36.   {
  37.     static CursorController the;
  38.     return the;
  39.   }
  40.  
  41. void CursorController::MouseMoved( const MouseEvent& event,
  42.                                               RegionObject& sleep )
  43.   {
  44.     const CursorObject *desired = 0;
  45.     
  46.     WindowObject *window = WindowObject::Front();
  47.     
  48.     if ( window == 0 )
  49.       {
  50.         desired = &CursorObject::Arrow();
  51.         sleep = Rectangle::big;
  52.       }
  53.      else
  54.         if ( window->StructureRegion().Contains( event.GlobalPoint() )
  55.               && window->ContentRegion().Contains( event.GlobalPoint() ) )
  56.           {
  57.             desired = &Application::The().LocateWindow( *window ).Cursor( event, sleep );
  58.             Assert( sleep.Contains( event.GlobalPoint() ) );
  59.           }
  60.          else
  61.           {
  62.             desired = &CursorObject::Arrow();
  63.             sleep = Rectangle::big;
  64.             sleep -= window->ContentRegion();
  65.           }
  66.     
  67.     if ( watchShowing || current != desired )
  68.       {
  69.         watchShowing = false;
  70.         current = desired;
  71.         current->Show();
  72.       }
  73.   }
  74.  
  75. void CursorController::ShowWatch()
  76.   {
  77.     if ( watchShowing )
  78.         return;
  79.     
  80.     Invalidate();
  81.     CursorObject::Watch().Show();
  82.   }
  83.